//
//  HMNetworkTool.swift
//  WymanWeibo
//
//  Created by wyman on 16/4/11.
//  Copyright © 2016年 wyman. All rights reserved.
//

import UIKit
import AFNetworking
//swift枚举不仅有成员,还可以有属性,还可以有方法

enum HMNetworkErrorEnum: Int {
    case AccessTokenEmpty = -1
    
    case UidEmpty =  -2
    
    case RepeatLoadStatus = -3
    var errorDescripition: String {
        get{
            switch self {
            
              case  AccessTokenEmpty: return "access_token没有返回值"
             case  UidEmpty: return "access_token没有返回值"
                
                case RepeatLoadStatus: return "有人在加载微博数据"

            }
        }
    }
    
    //返回一个错误
    func error() ->NSError{
    return NSError(domain: "cn.itheima.net", code: self.rawValue, userInfo: ["errorDescripition":self.errorDescripition])
    
    }
}


class HMNetworkTool: AFHTTPSessionManager {

    //定义单例
    
    static let sharedInstanse: HMNetworkTool = {
    
        let tool = HMNetworkTool()
        tool.responseSerializer.acceptableContentTypes?.insert("text/plain")
        return tool
    }()
    
}
